//
//  JKTextView.swift
//  JKWeibo
//
//  Created by albert on 16/6/25.
//  Copyright © 2016年 albert. All rights reserved.
//  发微博的textView

import UIKit

class JKTextView: JKEmojiKeyboardTextView {

    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: nil)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        setupUI()
    }

    /** 初始化 */
    private func setupUI() {
        
        addSubview(placeHolderLabel)
    }
    
    // 布局
    override func layoutSubviews() {
        super.layoutSubviews()
        
        placeHolderLabel.x = 5
        placeHolderLabel.y = 8
    }
    
    /** 控制占位文字的显示和隐藏 */
    func textChange() {
        placeHolderLabel.hidden = hasText()
    }
    
    /** 占位文字 */
    private lazy var placeHolderLabel: UILabel = {
        let lb = UILabel()
        lb.font = UIFont.systemFontOfSize(18)
        
        lb.text = "分享新鲜事..."
        lb.textColor = UIColor.grayColor()
        lb.sizeToFit()
        self.font = lb.font
        
        return lb
    }()
}
